package com.song.JavaThread_day04.ch4_3;

import java.util.Date;
import java.util.concurrent.TimeUnit;

public class Task implements Runnable {

	private Date initDate;
	
	private String name;
	
	
	
	public Task(String name) {
		super();
		this.name = name;
		initDate = new Date();
	}



	public void run() {
		System.out.printf(" %s Task  %s :created on %s \n",Thread.currentThread().getName(),name ,initDate);
		System.out.printf(" %s Task  %s :start on %s \n",Thread.currentThread().getName(),name , new Date());
		try {
			Long duration  = (long) (Math.random() *10);
			System.out.printf(" %s Task  %s : doing in during %s \n",Thread.currentThread().getName(),name , duration);
			
			TimeUnit.SECONDS.sleep(duration);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.printf(" %s Task  %s :finish on %s \n",Thread.currentThread().getName(),name , new Date());
	}

}
